#include<bits/stdc++.h>
using namespace std;
int t;
int n;
int m;
int l;
int v;
int d[100000];
int vi[100000];
int a[100000];
int p[100000];
int ns;
int ms;
int main(){
    freopen("detect2.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for (int z=0;z<t;z++){
        cin>>n>>m>>l>>v;
        ns=n;
        for (int i=0;i<n;i++)
            cin>>d[i]>>vi[i]>>a[i];
        for(int i=0;i<m;i++)
            cin>>p[i];
        for (int i=0;i<n;i++){
            if (vi[i]<=v && a[i]==0){
                ns--;
                }
            else {
                if (a[i]!=0){
                    for(int j=0;j<m-1;j++){
                        if (p[j]<d[i] && p[j+1]>d[i]+(pow(v,2)-pow(vi[i],2))/(2*a[i])){
                            ns--;
                        }
                    }
                    if (p[m-1]<d[i] && l>d[i]+(pow(v,2)-pow(vi[i],2))/(2*a[i])){
                            ns--;
                        }
                }
                else if (vi[i]>v){
                    if (d[i]>p[m-1])
                        n--;
                }
            }
        }
        ms=ns;
        cout<<ns<<' '<<ms<<endl;
    }
    return 0;
}
